﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;

namespace Jizsoft.JFrame.Modeling.Web.Api
{
    public class MenuController : ApiController
    {
        [HttpGet]
        public SingleResult<GetListResult> List()
        {

            GetListResult result = new GetListResult();

            GetListResult.Item item2 = new GetListResult.Item();
            item2.Caption = "功能列表";
            item2.LinkUrl = "#";
            result.Items.Add(item2);

            GetListResult.Item item3 = new GetListResult.Item();
            item3.Caption = "新建文章";
            item3.LinkUrl = "/module/cms/article_create.html";
            item2.Items.Add(item3);

            GetListResult.Item item5 = new GetListResult.Item();
            item5.Caption = "字段类型列表";
            item5.LinkUrl = "/html/fieldtype-list.html";
            item2.Items.Add(item5);

            GetListResult.Item item6 = new GetListResult.Item();
            item6.Caption = "模型管理";
            item6.LinkUrl = "#";
            item2.Items.Add(item6);
            GetListResult.Item item6_1 = new GetListResult.Item();
            item6_1.Caption = "未发布列表";
            item6_1.LinkUrl = "/html/model-list.html";
            item6.Items.Add(item6_1);
            GetListResult.Item item6_2 = new GetListResult.Item();
            item6_2.Caption = "已发布列表";
            item6_2.LinkUrl = "/html/published-model-list.html";
            item6.Items.Add(item6_2);

            return new SingleResult<GetListResult>(result);
        }

    }


    public class SingleResult<T>
    {
        public bool IsSuccess { get; set; }
        public string Message { get; set; }
        public int ErrorCode { get; set; }
        public T Data { get; set; }
    
        public SingleResult(T data)
        {
            IsSuccess = true;
            ErrorCode = 0;
            Message = string.Empty;
            Data = data;
        }
    }

    public class GetListResult
    {
        public List<Item> Items = new List<Item>();

        public class Item
        {
            public List<Item> Items = new List<Item>();

            public string Caption { get; set; }

            public string LinkUrl { get; set; }
        }
    }
}
